layui.use(['form', 'jquery', 'layer'], function() {
	var form = layui.form,
		$ = $ = layui.$,
		layer = layui.layer;
	$(document).on('blur','input[type="text"]', function() {
		var value = $(this).val(),
			field = $(this).attr('name'),
			old_value = $(this).attr('data-old_value'),
			site_id = $(this).attr('data-site_id'),
			brand_sign = $(this).attr('data-brand_sign'),
			obj = $(this);
		if(value != old_value) {
			var app_data = {
				field: field,
				value: value,
				brand_sign: brand_sign,
				site_id: site_id
			};
			send_info(saveSiteBrandOptionUrl, app_data, function(data) {
				if(data.code != 1) {
					layer.msg(data.msg, {
						icon: 2,
						anim: 6
					});
					obj.val(old_value);
					return false;
				} else {
					layer.msg(data.msg, {
						icon: 1,
						anim: 6
					});
					parent.layui.table.reload('brand_list');
					return true;
				}
			})
		}
	})
	form.on('switch(sale_state_on)', function(data) {
		var app_data = {
			field: 'sale_state',
			value: data.elem.checked,
			goods_sku: $(this).attr('data-goods_sku'),
			site_id: $(this).attr('data-site_id'),
			sale_price_sign: ''
		};
		send_info(saveSitePriceInfoUrl, app_data, function(data) {
			if(data.code != 1) {
				layer.msg(data.msg, {
					icon: 2,
					anim: 6
				});
				return false;
			} else {
				layer.msg(data.msg, {
					icon: 1,
					anim: 6
				});
			}
		})
	})
})